using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using Thinxoft.HttpLib;

namespace Thinxoft.XedusLive
{
	public delegate void EventDelegate(string message);
	/// <summary>
	/// Summary description for InfoForm.
	/// </summary>
	public class InfoForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.RichTextBox txtStatus;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public InfoForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		public void DisplayInfo()
		{
			try
			{
				FileStream fs = new FileStream(HttpApplication.DATA_FOLDER + "log.txt",FileMode.Open,FileAccess.Read);
				StreamReader sr = new StreamReader(fs);
				string str = sr.ReadToEnd();
				txtStatus.Text = str;
				fs.Close();
				this.Show();
			}
			catch(Exception e)
			{
				txtStatus.Text = "data is being added, please hit regresh to try again";
			}
		}

		

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(InfoForm));
			this.txtStatus = new System.Windows.Forms.RichTextBox();
			this.SuspendLayout();
			// 
			// txtStatus
			// 
			this.txtStatus.Dock = System.Windows.Forms.DockStyle.Fill;
			this.txtStatus.Location = new System.Drawing.Point(0, 0);
			this.txtStatus.Name = "txtStatus";
			this.txtStatus.Size = new System.Drawing.Size(489, 381);
			this.txtStatus.TabIndex = 0;
			this.txtStatus.Text = "";
			// 
			// InfoForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(489, 381);
			this.Controls.Add(this.txtStatus);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "InfoForm";
			this.Text = "Xedus Information";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.DoClose);
			this.ResumeLayout(false);

		}
		#endregion

		private void DoClose(object sender, System.ComponentModel.CancelEventArgs e)
		{
			e.Cancel = true;
			this.Hide();
		}
	}
}
